package com.heima.feign.clients;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.feign.clients.fallback.WemediaClientFallbackFactory;
import com.heima.feign.config.HeimaFeignAutoConfiguration;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "leadnews-wemedia", fallbackFactory = WemediaClientFallbackFactory.class, configuration = HeimaFeignAutoConfiguration.class)
public interface WemediaClient {    //远程调用接口注意做好服务熔断降级策略

    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    @GetMapping("/api/v1/user/findByName/{name}")
    public ResponseResult<WmUser> findByName(@PathVariable("name") String name);

    /**
     *  leadnews-article 微服务处理文章发布-根据 id 查询文章信息
     * @param id
     * @return
     */
    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult<WmNews> queryWmNewsById(@PathVariable(value = "id")Integer id);

    /**
     *  leadnews-article 微服务处理文章发布-修改文章状态信息
     * @param wmNews
     * @return
     */
    @PutMapping("/api/v1/news/update")
    public ResponseResult updateWmNewsById(@RequestBody WmNews wmNews);
}
